package com.springboot.cloud.demos.ribbon.rest;

import com.springboot.cloud.common.core.entity.vo.Result;
import com.springboot.cloud.demos.entity.form.UserCouponForm;
import com.springboot.cloud.demos.entity.param.UserCouponQueryParam;
import com.springboot.cloud.demos.ribbon.service.UserCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class UserCouponController {

    @Autowired
    private UserCouponService userCouponService;

    @PostMapping("/userCoupon/conditions")
    public Result conditions(@RequestBody UserCouponQueryParam params) {
        return userCouponService.conditions(params);
    }

    @PostMapping("/userCoupon")
    public Result add(@RequestBody UserCouponForm userCouponForm) {
        return userCouponService.save(userCouponForm);
    }

    @PutMapping(value = "/userCoupon")
    public Result update(@RequestBody UserCouponForm userCoupon) {
        return userCouponService.update(userCoupon);
    }

    @GetMapping("/userCoupon/{userCouponId}")
    public Result get(@PathVariable(value = "userCouponId") String userCouponId) {
        return userCouponService.userCoupon(userCouponId);
    }

}
